<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script src="js/vue.js"></script>
<script src="js/util.js"></script>
<script src="js/axios.js"></script>
<script src="js/jquery.min.js"></script>
<body>
    <div id="app">
        <button type="button" @click="add()">添加</button>
        姓名：<input type="text" name="name" v-model="name">
        <button type="button" @click="findPage(1)">搜索</button>
        <table border="1" cellspacing="0">
            <tr>
                <td>编号</td>
                <td>姓名</td>
                <td>地址</td>
                <td>操作</td>
            </tr>
            <tr v-for="item in page.records">
                <td>{{item.id}}</td>
                <td>{{item.username}}</td>
                <td>{{item.address}}</td>
                <td>
                    <button type="button" @click="del(item.id)">删除</button>
                </td>
            </tr>
        </table>
        <a @click="findPage(1)">首页</a>
        <a @click="findPage(page.current-1)">上一页</a>
        <a @click="findPage(page.current+1)">下一页</a>
        <a @click="findPage(page.pages)">尾页</a>
    </div>
<script>
    new Vue({
        el:"#app",
        data:{
            page:{},
            name:""
        },
        created(){
            this.findPage(1)
        },
        methods:{
            add(){
                location.href="add.html";
            },
            findPage(pageIndex){
                axios.get("/order/findPage?pageIndex=" + pageIndex + "&name=" + this.name).then(res => {
                    this.page=res.data;
                })
            },
            del(id){
                axios.get("/order/del?id=" + id).then(res => {
                    this.findPage(1);
                })
            }
        }
    })
</script>
</body>
</html>